﻿<%@ WebHandler Language="C#" Class="AddLeaveword" %>

using System;
using System.Web;
using fanfu.Business;
using fanfu.Model;
using fanfu.Common;

public class AddLeaveword : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string LeaveName = HttpContext.Current.Request.Params["LeaveName"].ToString();
        string LeaveEmail = HttpContext.Current.Request.Params["LeaveEmail"].ToString();
        string LeaveUrl = HttpContext.Current.Request.Params["LeaveUrl"].ToString();
        string LeaveCaption = HttpContext.Current.Request.Params["LeaveCaption"].ToString();
        string LeaveContent = HttpContext.Current.Request.Params["LeaveContent"].ToString();
        string LeaveIP = HttpContext.Current.Request.Params["LeaveIP"].ToString();
        context.Response.Write(InsertReview(LeaveName, LeaveEmail, LeaveUrl, LeaveCaption,
            LeaveContent, LeaveIP));
    }
 
    public bool IsReusable {
        get {
            return false;
        }
        
    }

    public int InsertReview(string LeaveName, string LeaveEmail, string LeaveUrl, string LeaveCaption, string LeaveContent, string LeaveIP)
    {
        LeavewordModel leavewordModel = new LeavewordModel();
        leavewordModel.LeaveName = LeaveName;
        leavewordModel.LeaveEmail = LeaveEmail;
        leavewordModel.LeaveUrl = LeaveUrl;
        leavewordModel.LeaveCaption = LeaveCaption;
        leavewordModel.LeaveContent = LeaveContent;
        leavewordModel.LeaveIP = LeaveIP;
        leavewordModel.LeaveTime = DateTime.Now;
        leavewordModel.AnswerName = string.Empty;
        leavewordModel.AnswerContent = string.Empty;
        leavewordModel.AnswerTime = Convert.ToDateTime("1753-1-1");
        leavewordModel.AnswerFlag = (byte)LeavewordAnswerFlag.noAnswer;
        leavewordModel.Flag = (byte)LeavewordFlag.noVerify;
        return SqlHelper.ExecuteCommand(LeavewordModel.GetInsertSQL(), leavewordModel.ToSqlParameters());
    }
}